package lg.minecraft.plugin.entityclear.command;

import lg.minecraft.plugin.entityclear.manager.EntityTaskManager;
import lg.minecraft.plugin.entityclear.task.EntityClearTask;
import lg.minecraft.plugin.library.command.CommandContext;
import lg.minecraft.plugin.library.command.SubCommand;
import org.bukkit.command.CommandSender;

import java.util.Map;

/**
 * @author langle__
 * @version 1.0
 */
public class InfoCommand extends SubCommand {

    public InfoCommand() {
        super("info");
    }

    @Override
    public String getDescription() {
        return "查看任务信息";
    }

    @Override
    public void onCommand(CommandContext context) {
        CommandSender sender = context.getSender();
        sender.sendMessage("[§a实体清理§f] 清理任务信息:");
        for (Map.Entry<String, EntityClearTask> entry : EntityTaskManager.INSTANCE.getEntrySet()) {
            String name = entry.getKey();
            EntityClearTask task = entry.getValue();
            long timeLeft = task.getTimeLeft();
            sender.sendMessage("  任务名: " + name + " 剩余时间: " + (timeLeft / 1000) + "§7[" + timeLeft + "]");
        }
    }

}
